<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<HEAD>
		<style type="text/css">
			 body {
		       font-family: Arial, Helvetica, sans-serif;
		       font-size:12px;
		      }
		     fieldset {
		       padding:10px;
		       margin-top:5px;
		       border:1px solid #A4CDF2;
		       font-size:12px;
		        }
		     fieldset legend {
		       font-weight:bold;
		       font-size: 15px;  
		      }
		      div_footer{
		       text-align:center;
		      }
		      div.msgArea {
		        filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#FFFFFF',endColorStr='#3568CC',gradientType='1')
		      }
		      .select{
		        border-right: #000000 1px solid;
		        border-top: #ffffff 1px solid;
		        border-left: #ffffff 1px solid;
		        color:#003366;
		        border-bottom: #000000 1px solid;
		        background-color: #f4f4f4;
		        font-size:12px;
		    }
		      .textfield{
		        color:#003366; 
		        width:40px;
		        font-size:12px;
		      }
		    .btn_1{   
		        BORDER-RIGHT:#002D96 1px solid;   
		        PADDING-RIGHT:2px;   BORDER-TOP:#002D96 1px solid;   
		        PADDING-LEFT:2px;   
		        FONT-SIZE:12px;
		        FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#FFFFFF,EndColorStr=#9DBCEA);   
		        BORDER-LEFT:   #002D96   1px   solid;   
		        CURSOR:hand;   
		        COLOR: black;   
		        PADDING-TOP:2px;   
		        BORDER-BOTTOM:#002D96 1px solid 
		        font-size:12px;  
		    }
		     .textarea{
		        color: #003366;
		        font-size:12px;   
		    }
		     .textfield_2{
		        color:#003366; 
		        width:80px;
		        font-size:12px;
		      }
		 </style>
		<script language="javascript" type="text/javascript">
		function checkDate(strDate,typeName)
		{
		    var check = /^([1-2]\d{3})\/([1-9]|0[1-9]|1[0-2])\/([1-2][0-9]|[1-9]|0[1-9]|3[0-1])$/;
		
		    if(strDate != "")
		    {
		        if (check.test(strDate) == false)
		        {
		            alert(typeName+"_年を入力不正");
		            return false;
		        }
		        else
		        {
		            var y = (strDate).split("/")[0];
		            var m = (strDate).split("/")[1];
		            var d = (strDate).split("/")[2];
		            if(m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
		            {
		                if(d < 0 || d > 31)
		                {
		                    alert(typeName+"_日を選択不正");
		                    return false;
		                }
		                else
		                {
		                    return true;
		                }
		            }
		            else
		            {
		                if(m == 2)
		                {
		                    if(y % 400 == 0 || (y % 4 == 0 && y % 100 != 0))
		                    {
		                        if(d < 1 || d > 29)
		                        {
		                            alert(typeName+"_日を選択不正");
		                            return false;
		                        }
		                        else
		                        {
		                            return true;
		                        }
		                    }
		                    else
		                    {
		                        if(d < 1 || d > 28)
		                        {
		                            alert(typeName+"_日を選択不正");
		                            return false;
		                        }
		                        else
		                        {
		                            return true;
		                        }
		                    }
		                }
		                else
		                {
		                    if(d < 1 || d > 30)
		                    {
		                        alert(typeName+"_日を選択不正");
		                        return false;
		                    }
		                    else
		                    {
		                        return true;
		                    }
		                }
		            }
		        }
		    }
		    else
		    {
		       return false;
		    }
		}
		function dateCompare(d1,d2,flag)
		{
		    if (Date.parse(d1) - Date.parse(d2) > 0)
		    {
		    	if(flag == "1"){
		        	window.alert("回答期限が、提出日付より過去日付になっているので修正して下さい。");
		        }
		        else{
		        	window.alert("確認日付が、回答日付より過去日付になっているので修正して下さい。");
		        }
		        return false;
		    }else{
		    	return true;
		    }
		}
		
		function formCheck(){
		
			var limitDateY = document.getElementById("limitDateY");
			var limitDateM = document.getElementById("limitDateM");
			var limitDateD = document.getElementById("limitDateD");
			
			var ConfirmDateY = document.getElementById("ConfirmDateY");
			var ConfirmDateM = document.getElementById("ConfirmDateM");
			var ConfirmDateD = document.getElementById("ConfirmDateD");
			
			var inputDate = document.getElementById("InputDate").innerText;
			var AnswerDate = document.getElementById("AnswerDate").innerText;
			var limitDate = limitDateY.value+"/"+limitDateM.value+"/"+limitDateD.value;
			var ConfirmDate = ConfirmDateY.value+"/"+ConfirmDateM.value+"/"+ConfirmDateD.value;
			
			var selBanGo = document.getElementById("selBanGo").value;
			var Confirmer = document.getElementById("confirmer").value;
			var status = document.getElementById("status").value;
			var currentStatus = document.getElementById("currentStatus").value;
			
			if(!checkDate(limitDate,"回答期限")) {
				return false;
			}
			if(!dateCompare(inputDate,limitDate,"1")) {
				return false;
			}
		
			if(currentStatus == 1 || currentStatus == 2) {
			if(!(Confirmer==""&&ConfirmDateY.value==""&&status == "回答済")) {
				if(Confirmer==""){
					alert("確認者を入力ください");
					return false;
				}else if(status == "回答済"){
					alert("状態を選択ください");
					return false;
				}else if(ConfirmDateY.value==""){
					alert("確認日付_年を入力ください");
					return false;
				}else if(ConfirmDateM.value==""){
					alert("確認日付_月を選択ください");
					return false;
				}else if(ConfirmDateD.value==""){
					alert("確認日付_日を選択ください");
					return false;
				}
			}
			}
			if(!(ConfirmDateY.value==""&&ConfirmDateM.value==""&&ConfirmDateD.value=="")) {
				if(!checkDate(ConfirmDate,"確認日付")) {
					return false;
				}
				if(!dateCompare(AnswerDate,ConfirmDate,0)){
					return false;
				}
			}
		
			if(selBanGo.replace(/^\s+|\s+$/g,"")==""){
				alert("質問詳細を入力ください");
				return false;
			}
		}
		</script>
    	<TITLE>
			QA詳細一覧
		</TITLE>
	</HEAD>
<body text=#003366>
<s:form method="POST" enctype='multipart/form-data'  theme="simple">
<div id="viewEditArea">
<div id="contentArea">
<fieldset><legend>QA詳細一覧</legend>
<table width=70% align=center>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">プロジェクト</td>
				<td align="left" style="font-size:12px;"><s:property value="detailList.project" /></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">テーマ名</td>
				<td align="left" style="font-size:12px;"><s:property value="detailList.tema" /></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">段階</td>
				<td align="left" style="font-size:12px;"><s:property value="detailList.dankai" /></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">発生箇所</td>
				<td align="left" style="font-size:12px;"><s:property value="detailList.Kasho" /></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">提出者</td>
				<td align="left" style="font-size:12px;"><s:property value="detailList.Asker" /></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">提出日付</td>
				<td align="left" id="InputDate" style="font-size:12px;"><s:property value="detailList.InputDate" /></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">回答日付</td>
				<td align="left" id="AnswerDate" style="font-size:12px;">
					<s:if test="currentStatus == 0">
						<s:date name="currentDate" format="yyyy/MM/dd" />
					</s:if>
					<s:else>
						<s:property value="detailList.AnswerDate" />
					</s:else>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">回答期限</td>
				<td align="left" style="font-size:12px;">
				<input id="limitDateY" name="detailList.limitDateY" size="1" maxlength="4" value="<s:property value="limitDateSub[0]" />" class="textfield" />年
				<s:select id="limitDateM" name="detailList.limitDateM" list="monthList" listKey="month" listValue="month" value="limitDateSub[1]" theme="simple" cssClass="select"/>月
				<s:select id="limitDateD" name="detailList.limitDateD" list="dayList" listKey="day" listValue="day" value="limitDateSub[2]" theme="simple" cssClass="select"/>日
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">状態</td>
				<td align="left" style="font-size:12px;">
				<s:select id="status" name="detailList.status" list="StatusList" listKey="master_value" listValue="master_value" theme="simple" cssClass="select"/>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<s:if test="currentStatus != 0">
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">確認者</td>
				<td align="left" style="font-size:12px;">
				<s:if test="currentStatus == 0">
					<input id="confirmer" type="text" size="7" maxlength="10" name="detailList.confirmer" value="" disabled="true" class="textfield_2"/>
				</s:if>
				<s:elseif test="currentStatus == 1">
					<input id="confirmer" type="text" size="7" maxlength="10" name="detailList.confirmer" value="" class="textfield_2"/>
				</s:elseif>
				<s:else>
					<input id="confirmer" type="text" size="7" maxlength="10" name="detailList.confirmer" value="<s:property value="detailList.Confirmer" />" class="textfield_2"/>
				</s:else>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">確認日付</td>
				<td align="left" style="font-size:12px;">
				<s:if test="currentStatus == 0">
					<input type="text" id="ConfirmDateY" name="detailList.confirmDateY" size="1" maxlength="4" value="" disabled="true" class="textfield"/>年
					<s:select id="ConfirmDateM" name="detailList.confirmDateM" list="monthList" listKey="month" listValue="month" headerKey="" headerValue="" value="" theme="simple" disabled="true" cssClass="select"/>月
					<s:select id="ConfirmDateD" name="detailList.confirmDateD" list="dayList" listKey="day" listValue="day" headerKey="" headerValue="" value="" theme="simple" disabled="true" cssClass="select"/>日
				</s:if>
				<s:else>
				    <s:if test="currentStatus == 1">
					<input type="text" id="ConfirmDateY" name="detailList.confirmDateY" size="1" maxlength="4" value="" class="textfield"/>年
					<s:select id="ConfirmDateM" name="detailList.confirmDateM" list="monthList" listKey="month" listValue="month" headerKey="" headerValue="" value="" theme="simple" cssClass="select"/>月
					<s:select id="ConfirmDateD" name="detailList.confirmDateD" list="dayList" listKey="day" listValue="day" headerKey="" headerValue="" value="" theme="simple" cssClass="select"/>日
					</s:if>
					<s:else>
						<input  type="text" id="ConfirmDateY" name="detailList.confirmDateY" size="1" maxlength="4" value="<s:property value="confirmDateSub[0]" />" class="textfield"/>年
						<s:select id="ConfirmDateM" name="detailList.confirmDateM" list="monthList" listKey="month" listValue="month" value="confirmDateSub[1]" theme="simple" cssClass="select"/>月
						<s:select id="ConfirmDateD" name="detailList.confirmDateD" list="dayList" listKey="day" listValue="day" value="confirmDateSub[2]" theme="simple" cssClass="select"/>日
					</s:else>
				</s:else>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	</s:if>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">緊急度</td>
				<td align="left" style="font-size:12px;">
				<s:select name="detailList.emergencyDegree" list="EmergencyDegreeList" listKey="master_value" listValue="master_value" theme="simple" cssClass="select"/>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">問合先</td>
				<td align="left" style="font-size:12px;">
				<s:select name="detailList.toIAWaSeSaKi" list="AskedArray" listKey="user_disp_value" listValue="user_disp_value" theme="simple" cssClass="select"/>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">質問詳細</td>
				<td style="font-size:12px;"><textarea id="selBanGo" rows=10 cols=50 name="detailList.selBanGo" class="textarea"><s:property value="detailList.SelBanGo" /></textarea>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">回答内容</td>
				<td style="font-size:12px;"><textarea rows=10 cols=50 name="detailList.naiYo" class="textarea"><s:property value="detailList.NaiYo" /></textarea>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">備考</td>
				<td style="font-size:12px;">
				<textarea rows=10 cols=50 name="detailList.biko" class="textarea"><s:property value="detailList.biko" /></textarea>
				</td>
			</tr>
		</table>
		</td>
	</tr><!--SQLite JDBC Driver has't supported BLOB type yet.So disabled download function.
	<tr>
		<td bgcolor=RGB(221,230,247)>
		<table width=100%>
			<tr>
				<td width=30% style="font-size:12px;">添付資料</td>
				<td align="left" style="font-size:12px;">依頼| <a href="qaDownload.action?bango=<s:property value="detailList.banGo" />&direction=QA_FILE_FROM"><s:property value="detailList.fromShiRyouname" /></a></td>
				<td align="left" style="font-size:12px;">回答| <a href="qaDownload.action?bango=<s:property value="detailList.banGo" />&direction=QA_FILE_TO"><s:property value="detailList.toShiRyouname" /></a></td>
				<td style="font-size:12px;"><input type="file" name ="myFile" theme = "simple" labelposition = "right" oncontextmenu="window.event.returnValue=false;" onkeydown="return false;"/></td>
			</tr>
		</table>
		</td>
	</tr>-->
</table>
</fieldset>
</div>

<table cellspacing="5" summary="隙間用">
	<tr>
		<td></td>
	</tr>
</table>
</div>

<div class="cmdArea">
<br>
<table class="cmdLine" cellpadding="0" cellspacing="0" width="100%"
	summary="コマンド用" bgcolor=RGB(238,242,251)>
	<tr>
		<td width=15%></td>
		<td width="15%" align="right"><s:submit btnId="C012" theme="simple" value="閉   じ  る" onclick="javascript:window.close();return false;" cssClass="btn_1"/></td>
		<td width="40%"></td>
		<td width="15%"><s:submit btnId="C013" action="qaModify" value="完     了" theme="simple" onclick="return formCheck()" cssClass="btn_1"/>
		</td>
		<td width="15%"></td>
	</tr>
</table>
</div>

<table cellspacing="30" summary="隙間用">
	<tr>
		<td>
		<input type="hidden" id="currentStatus"  value="<s:property value="currentStatus" />" />
		<input type="hidden" id="banGo" name="detailList.banGo" value="<s:property value="bango" />" />
		
		</td>
	</tr>
</table>
</s:form>
</body>
</html>
